<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>修改商户</title>
		<link rel="stylesheet" href="../../../bangnuo/admin/layui/css/layui.css">
	</head>
 
	<body>

		<div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin" style="padding: 20px 0 0 0;">
			<div class="layui-form-item">
				<label class="layui-form-label">商户编号</label>
				<div class="layui-input-inline">
					<input type="text" name="merchantsNumber" id="merchantsNumber" lay-verify="required" placeholder="请输入商户编号" autocomplete="off" class="layui-input"   readonly="readonly">
					<input type="hidden" name="merchantsUuid" id="merchantsUuid" lay-verify="required" placeholder="请输入id" autocomplete="off" class="layui-input"   readonly="readonly">
				</div> 
				<div class="layui-form-mid layui-word-red" style="color: red;">商户编号不可修改</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">商户名称</label>
				<div class="layui-input-inline">
					<input type="text" name="merchantsCompanyName" id="merchantsCompanyName" lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
				</div> 
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">登录名</label>
				<div class="layui-input-inline">
					<input type="text" name="merchantsUsername" id="merchantsUsername" lay-verify="required" placeholder="请输入登录名" autocomplete="off" class="layui-input"  readonly="readonly">
				</div>
				<div class="layui-form-mid layui-word-red" style="color: red;">商户登录名不可修改</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">密码</label>
				<div class="layui-input-inline">
					<input type="text" name="merchantsPassword" id="merchantsPassword" lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">负责人姓名</label>
				<div class="layui-input-inline">
					<input type="text" name="merchantsName" id="merchantsName" lay-verify="required" placeholder="请输入负责人姓名" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">电话</label>
				<div class="layui-input-inline">
					<input type="text" name="merchantsPhone" id="merchantsPhone" lay-verify="required" placeholder="请输入手机号" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">电子邮箱</label>
				<div class="layui-input-inline">
					<input type="text" name="merchantsEmail" id="merchantsEmail" lay-verify="required" placeholder="请输入邮箱账号" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">支付宝账号</label>
				<div class="layui-input-inline">
					<input type="text" name="merchantsZFBUsername" id="merchantsZFBUsername" lay-verify="required" placeholder="请输入支付宝账号" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">职务</label>
				<div class="layui-input-inline">
					<input type="text" name="merchantsPosition" id="merchantsPosition" lay-verify="required" placeholder="请输入你的职务" autocomplete="off" class="layui-input">
				</div>
				<div class="layui-form-mid layui-word-red" style="color: red;">法人 董事长 总经理 市场经理 老板 老板娘 财务 行政 技术</div>
			</div>
			<div class="layui-form-item" lay-filter="sex">
				<label class="layui-form-label">商户类型</label>
				<div class="layui-input-block">
					<input type="radio" name="merchantsType" value="0" title="公司" checked>
					<input type="radio" name="merchantsType" value="1" title="个人">
					<input type="radio" name="merchantsType" value="2" title="个体户">
				</div>
			</div>
			<div class="layui-form-item" lay-filter="sex">
				<label class="layui-form-label">账号状态</label>
				<div class="layui-input-block">
					<input type="radio" name="merchantsState" value="0" title="正常" checked>
					<input type="radio" name="merchantsState" value="1" title="冻结">
				</div>
			</div>
				<div class="layui-form-item" lay-filter="sex">
				<label class="layui-form-label">通道</label>
				<div class="layui-input-block">
					<input type="radio" name="merchantsChannel" value="0" title="支付宝" checked>
					<input type="radio" name="merchantsChannel" value="1" title="微信">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">上级代理</label>
				<div class="layui-input-block" style="width: 200px;">
					<select name="merchantsIdAgentId" id="agentIdAgentId">
					</select>
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">专属业务员</label>
				<div class="layui-input-block" style="width: 200px;">
					<select name="employeeId" id="employeeId">
					</select>
				</div>
			</div>

			<div class="layui-form-item" id="area-picker">
				<div class="layui-form-label">地址</div>
				<div class="layui-input-inline" style="width: 200px;">
					<select name="merchantsProvince" class="province-selector" data-value="广东省" lay-filter="province-1">
						<option value="">请选择省</option>
					</select>
				</div>
				<div class="layui-input-inline" style="width: 200px;">
					<select name="merchantsCity" class="city-selector" data-value="深圳市" lay-filter="city-1">
						<option value="">请选择市</option>
					</select>
				</div>
				<div class="layui-input-inline" style="width: 200px;">
					<select name="merchantsArea" class="county-selector" data-value="龙岗区" lay-filter="county-1">
						<option value="">请选择区</option>
					</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">详细地址</label>
				<div class="layui-input-inline">
					<input type="text" name="merchantsAddress" id="merchantsAddress" lay-verify="required" placeholder="请输入详细地址" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">备注</label>
				<div class="layui-input-inline">
					<input type="text" name="merchantsNote" id="merchantsNote" placeholder="请输入备注" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-btn-container" style="padding-bottom: 10px; margin-left: 110px; margin-right: -110px;">
				<button class="layui-btn" lay-submit lay-filter="admin-form" data-type="close">立即提交</button>
			</div>
		</div>
	</body>
	<script src="../../../bangnuo/admin/layui/layui.js"></script>
	
	<script>
		       //配置插件目录
        layui.config({
            base: '../../../bangnuo/admin/'
           
        });
        //一般直接写在一个js文件中
        layui.use(['layer', 'form', 'layarea'], function () {
            var layer = layui.layer
                , form = layui.form
                , layarea = layui.layarea;
            layarea.render({
                elem: '#area-picker',
                change: function (res) {
                    //选择结果
                    console.log(res);
                } 
            });
        });
	</script>
	<script src="../../../bangnuo/admin/js/jquery-1.8.0.min.js"></script>
	<script>
		layui.use(['form', 'upload', 'layer'], function() {


			var form = layui.form;

            $.ajax({
                type: "GET",
                url: '/agentEntity/findAgent',
                dataType:"json",
                contentType: "application/json;charset=UTF-8",
                success: function(res){
                    var html2 = '<option value="">'+res.object.companyName+'</option>';
                    if(res.success){
                        $("#agentIdAgentId").html(html2);
                        form.render('select');
                    }
                }
            });

            $.ajax({
                type: "GET",
                url: '/adminEntity/findAllByAgentId',
                dataType:"json",
                contentType: "application/json;charset=UTF-8",
                success: function(res){
                    var html2 = '<option value="">请选择</option>';
                    if(res.success){
                        for(var i=0;i<res.queryResult.list.length;i++){
                            html2 = html2 + '<option value="'+res.queryResult.list[i].id+'">'+res.queryResult.list[i].name+'</option>';
                        }
                        $("#employeeId").html(html2);
                        form.render('select');
                    }
                }
            });




		});
	</script>
	<script>
		 layui.use(['form', 'upload', 'layer'], function() {

			var form = layui.form;
			
			var resultData;
			var htmls = '<option value="">请选择</option>'; //全局变量

			//检查项目添加到下拉框中
			$.ajax({
				url: 'http://192.168.101.93:2601/adminEntity/admin',
				dataType: 'json',
				type: 'get',
				success: function(data) {
					resultData = data.data;                       
					for(var x in resultData) {                            
					htmls += '<option value = "' + resultData[x].value + '">' + resultData[x].name + '</option>';                      
					} 
					$("#merchantsIdAdminId").html(htmls);
					form.render('select');

					//重新渲染 固定写法
				}
			})
		});
	</script>
	 <script type="text/javascript">
        $(document).ready(function(){
        	//获取地址栏路径
        	var url = window.location.href;
        	//获取“=”的下标
        	var pos = url.indexOf("=");
        	//获取“=”后的全部字符（用户id）
        	var id = url.substring(pos+1,url.length); 
        		$.ajax({
            		url : "http://localhost:2603/merchantsEntity/merchantsById/"+id,
            		contentType:"application/json;charset=UTF-8",
            		type : "GET",
            		success : function(data){
            			$("#merchantsUuid").val(data.data.merchantsUuid);
            			$("#merchantsNumber").val(data.data.merchantsNumber);
            			$("#merchantsCompanyName").val(data.data.merchantsCompanyName)
            			$("#merchantsUsername").val(data.data.merchantsUsername);
            			$("#merchantsPassword").val(data.data.merchantsPassword);
            			$("#merchantsName").val(data.data.merchantsName);
            			$("#merchantsPhone").val(data.data.merchantsPhone);
            			$("#merchantsEmail").val(data.data.merchantsEmail);
            			$("#merchantsZFBUsername").val(data.data.merchantsZFBUsername);
            			$("#merchantsPosition").val(data.data.merchantsPosition);
            			$("#merchantsAddress").val(data.data.merchantsAddress);
            			
            		}
            	});
        });
        </script>
	<!--加载表单组件样式-->
	<script>
		layui.config({
			base: '../../../bangnuo/admin/' //静态资源所在路径
		}).extend({
			index: 'lib/index' //主入口模块
		}).use(['index', 'form', 'upload'], function() {
			var $ = layui.$,
				form = layui.form,
				upload = layui.upload;

			upload.render({
				elem: '#layuiadmin-upload-useradmin',
				url: layui.setter.base + 'json/upload/demo.js',
				accept: 'images',
				method: 'get',
				acceptMime: 'image/*',
				done: function(res) {
					$(this.item).prev("div").children("input").val(res.data.src)
				}
			});
		})
	</script>
	<!--获取表单信息，提交表单-->
	<script type="text/javascript">
		layui.use('form', function() {
			var form = layui.form;
			//监听提交
			form.on('submit(admin-form)', function(data) {
				layer.msg(JSON.stringify(data.field));
				$.ajax({
					type: "POST",
					url: "http://192.168.101.93:2603/merchantsEntity/upMerchants",
					contentType: "application/json;charset=UTF-8",
					data: JSON.stringify(data.field),
					async: true,
					success: function(data) {
						if(data.flag == true) {
							//layer.msg(data.message);
						} else {
							//layer.msg(data.message);
						}
					}
				});
				return false;
			});
		});
	</script>
	<!--关闭弹层-->
		<script>
			layui.use('layer', function() {
				var $ = layui.$,
					layer = layui.layer,
					index = parent.layer.getFrameIndex(window.name); //获取窗口索引
				var active = {
					close: function() {
						var id = '#LAY_layer_iframe_demo',
							mark = $('#LAY_mark');
						parent.layer.msg('修改成功');
						parent.layer.tips('Look here', id, {
							time: 5000
						});
						window.parent.location.reload();
						parent.layer.close(index);
					}
				}
				$('.layui-btn-container .layui-btn').on('click', function() {
					var othis = $(this),
						type = othis.data('type');
					active[type] && active[type].call(this);
				});
			});
		</script>

</html>